#include <memory>
#include <unistd.h>
#include "Thread.hpp"

void *thread_run(void *args)
{
    std::string work_type = static_cast<const char*>(args);
    while(true)
    {
        std::cout << "我是一个新线程, 我正在做: " << work_type << std::endl;
        sleep(1); 
    }
}

int main()
{
    //构造线程对象的时候，构造函数内部就会创建线程，让线程跑起来
    std::unique_ptr<Thread> thread1(new Thread(thread_run, (void *)"hello_thread", 1));
    std::unique_ptr<Thread> thread2(new Thread(thread_run, (void *)"count_thread", 2));
    std::unique_ptr<Thread> thread3(new Thread(thread_run, (void *)"log_thread", 3));
    
    thread1->join();
    thread2->join();
    thread3->join();
    
    return 0;
}









